package com.fitness.front.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fitness.front.modal.course.entity.CourseReserve;
import com.fitness.front.modal.course.params.CourseReserveQueryParams;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface CourseReserveMapper extends BaseMapper<CourseReserve> {

    @Select("<script>select * from t_course_reserve c "
            + " <where>"
            + "<if test='queryParams.courseName != null and queryParams.courseName.trim() neq \"\"'>"
            + " AND c.name like  CONCAT('%',#{queryParams.courseName},'%')"
            + "</if>"
            + "<if test='queryParams.status != null'>"
            + " AND c.status = #{queryParams.status}"
            + "</if>"
            + " AND c.member_id = #{memberId} "
            + "</where>"
            + " ORDER BY update_time desc"
            +"</script>")
    Page<CourseReserve> getCourseReservePage(Page<CourseReserve> page,@Param("memberId") Long memberId,@Param("queryParams") CourseReserveQueryParams queryParams);
}
